const express = require('express')
const router = express.Router()

// 导入解析 formdata 格式表单数据的包
const multer = require('multer')
// 导入处理路径的核心模块
const path = require('path')

const expressJoi = require('@escook/express-joi')

const { addArticle ,getArticleList, deleteArticleList} = require('../router_handler/articles')
// 文章发布模块
const uploads = multer({ dest: path.join(__dirname, '../uploads') })

const { add_article_schema ,delelt_article_schema} = require('../schema/article')

router.post('/add', uploads.single('cover_img'), expressJoi(add_article_schema), addArticle)
router.get('/list', getArticleList)
router.get('/deletelist/:Id', expressJoi(delelt_article_schema), deleteArticleList)

module.exports = router